package com.example.myspringbootpj.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.myspringbootpj.entity.Manage;

import com.example.myspringbootpj.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper extends BaseMapper<Manage> {
    @Select("""
select * from manage where manage_id=#{manage_id} and manage.manage_password=#{manage_password}""")
    @Results({
            @Result(column = "manage_id", property = "manage_id"),
            @Result(column = "manage_password", property = "manage_password")
    })
    Manage selectManage(String manage_id,String manage_password);

    @Select("""
select user_name,user_id from user where user_not_use>CURRENT_DATE""")
    @Results({
            @Result(column = "user_id", property = "user_id"),
            @Result(column = "user_name", property = "user_name")
    })
    List<User> getBanUsers();

    @Select("""
select user_name,user_id from user where user_not_use<CURRENT_DATE""")
    @Results({
            @Result(column = "user_id", property = "user_id"),
            @Result(column = "user_name", property = "user_name")
    })
    List<User> getNotBanUsers();

    @Select("""
select user_name,user_id from user""")
    @Results({
            @Result(column = "user_id", property = "user_id"),
            @Result(column = "user_name", property = "user_name")
    })
    List<User> getAllUsers();

    @Delete("""
delete from user where user_id=#{user_id}""")
    int deleteUser(String userId);

}
